package leetcode_core.leetcode_3;

public class RemoveElement {
    public int removeElement(int[] nums, int val) {
        if(nums.length == 0){
            return 0;
        }
        if(nums.length == 1){
            return nums[0] == val ? 0:1;
        }
        int slow = 0;
        int fast = slow+1;
        while (fast < nums.length){
            int cur = nums[fast];
            if(cur == val){
                fast++;
                continue;
            }
            nums[slow++] = cur;
            fast++;
        }
        return slow;
    }
}
